function findCostInfo() {
	//申请中的预算
	$certusUtils.ajax("findActualBugets", { "proId": proId, "status": 1 }, function (response) {
		// 立项信息-项目指标
		var other2Columns = [{
			id: 'buget_phase',
			title: '阶段',
			type: 'string',
			width: 100,
			columnClass: 'text-center',
		}, {
			id: 'buget_type',
			title: '类型',
			type: 'string',
			width: 100,
			columnClass: 'text-center',
		}, {
			id: 'fmBuget',
			title: '金额',
			type: 'string',
			width: 150,
			columnClass: 'text-center',
			resolution: function (value, record, column, grid, dataNo, columnNo) {
				var content = '￥' + value + '元';
				return content;
			}
		}, {
			id: 'user_name',
			title: '申请人',
			type: 'string',
			width: 75,
			columnClass: 'text-center'
		}, {
			id: 'create_time',
			title: '申请时间',
			type: 'date',
			width: 100,
			format: 'yyyy-MM-dd',
			otype: 'time_stamp_ms',
			columnClass: 'text-center'
		}, {
			id: 'useTimeSycle',
			title: '使用周期',
			type: 'string',
			width: 200,
			columnClass: 'text-center',
			resolution: function (value, record, column, grid, dataNo, columnNo) {
				var content = '';
				if (record.budgetBegin == null || record.budgetBegin == "" || record.budgetBegin == undefined) {
					return content;
				} else {
					content += record.budgetBegin + "至" + record.budgetEnd;
					return content;
				}
			}
		}, {
			id: 'comments',
			title: '费用说明',
			type: 'string',
			columnClass: 'text-left'
		}];

		$("#otherContainer").empty();
		var other2Option = {
			lang: 'zh-cn',
			ajaxLoad: false,
			extraWidth: 20,
			// loadURL:'url',
			exportFileName: '其他费用',
			datas: response.data,
			columns: other2Columns,
			gridContainer: 'otherContainer',
			tools: ''
		};
		var other1Grid = $.fn.dlshouwen.grid.init(other2Option);
		other1Grid.load();
	});

	//报销费用
	// $certusUtils.ajax("findBxInfo", { "projId": proId, "status": 0 }, function (response) {
	// 	var other2Columns = [{
	// 		id: 'tri_class_name',
	// 		title: '类型',
	// 		type: 'string',
	// 		width: 100,
	// 		columnClass: 'text-center',
	// 	}, {
	// 		id: 'money',
	// 		title: '金额',
	// 		type: 'string',
	// 		width: 150,
	// 		columnClass: 'text-center',
	// 		resolution: function (value, record, column, grid, dataNo, columnNo) {
	// 			var content = '￥' + value + '元';
	// 			return content;
	// 		}
	// 	}, {
	// 		id: 'user_name',
	// 		title: '申请人',
	// 		type: 'string',
	// 		width: 75,
	// 		columnClass: 'text-center'
	// 	}, {
	// 		id: 'create_time',
	// 		title: '申请时间',
	// 		type: 'date',
	// 		width: 100,
	// 		format: 'yyyy-MM-dd',
	// 		otype: 'time_stamp_ms',
	// 		columnClass: 'text-center'
	// 	}, {
	// 		id: 'useTimeSycle',
	// 		title: '使用周期',
	// 		type: 'string',
	// 		width: 200,
	// 		columnClass: 'text-center',
	// 		resolution: function (value, record, column, grid, dataNo, columnNo) {
	// 			var content = '';
	// 			// content += record.start_date + "至" + record.end_date;
	// 			if(record.start_date == "" || record.start_date == null || record.start_date == undefined){
	// 				return content;
	// 			}else{
	// 				content += record.start_date + "至" + record.end_date;
	// 				return content;
	// 			}
	//
	// 		}
	// 	}, {
	// 		id: 'tr_instruction',
	// 		title: '费用说明',
	// 		type: 'string',
	// 		columnClass: 'text-center'
	// 	}];
    //
	// 	$("#bxContainer").empty();
    //
	// 	var other2Option = {
	// 		lang: 'zh-cn',
	// 		ajaxLoad: false,
	// 		extraWidth: 20,
	// 		// loadURL:'url',
	// 		exportFileName: '其他费用',
	// 		datas: response.data,
	// 		columns: other2Columns,
	// 		gridContainer: 'bxContainer',
	// 		tools: ''
	// 	};
	// 	var other1Grid = $.fn.dlshouwen.grid.init(other2Option);
	// 	other1Grid.load();
	// });

	$certusUtils.ajax("findYsBuget", { "proId": proId }, function (response) {
		var other1Columns = [{
			id: 'buget_phase',
			title: '阶段',
			type: 'string',
			width: 100,
			columnClass: 'text-center',
		}, {
			id: 'buget_type',
			title: '类型',
			type: 'string',
			width: 100,
			columnClass: 'text-center',
		}, {
			id: 'buget',
			title: '金额',
			type: 'string',
			width: 150,
			columnClass: 'text-center',
			resolution: function (value, record, column, grid, dataNo, columnNo) {
				var content = '￥' + value + '元';
				return content;
			}
		}, {
			id: 'user_name',
			title: '申请人',
			type: 'string',
			width: 75,
			columnClass: 'text-center'
		}, {
			id: 'create_time',
			title: '申请时间',
			type: 'date',
			format: 'yyyy-MM-dd',
			otype: 'time_stamp_ms',
			width: 100,
			columnClass: 'text-center'
		}, {
			id: 'budget_begin',
			title: '使用周期',
			type: 'string',
			width: 200,
			columnClass: 'text-center',
			resolution: function (value, record, column, grid, dataNo, columnNo) {
				var content = '';
				if (record.budgetBegin == "" || record.budgetBegin == undefined || record.budgetBegin == null) {
					return content;
				} else {
					content += record.budgetBegin + "至" + record.budgetEnd;
					return content;
				}
			}
		}, {
			id: 'comments',
			title: '费用说明',
			type: 'string',
			columnClass: 'text-left'
		}];
		var other1Option = {
			lang: 'zh-cn',
			ajaxLoad: false,
			// loadURL:'url',
			extraWidth: 20,
			exportFileName: '其他费用',
			datas: response.data,
			columns: other1Columns,
			gridContainer: 'other1Container',
			tools: ''
		};
		var other1Grid = $.fn.dlshouwen.grid.init(other1Option);
		other1Grid.load();
	});
	this.searchTotal = function () {
        $certusUtils.ajax("findTotalMoney", { "proId": proId, "status": 1,"isFy":0 }, function (response) {
        	var m = 0;
        	if (response.data != ""){
        		m = response.data;
			}
            $("#totalMoney").html(m);
        });
    };
    searchTotal();

	function loadTotalBuget() {
		$certusUtils.ajax("findBugetInfo2", { "proId": proId, "status": 1,"isFy":0 }, function (response) {
			// 立项信息-项目指标
			var other2Columns = [{
				id: 'buget_phase',
				title: '阶段',
				type: 'string',
				width: 100,
				columnClass: 'text-center',
			}, {
				id: 'buget_type',
				title: '类型',
				type: 'string',
				width: 100,
				columnClass: 'text-center',
			}, {
				id: 'fmBuget',
				title: '金额',
				type: 'string',
				width: 150,
				columnClass: 'text-center',
				resolution: function (value, record, column, grid, dataNo, columnNo) {
					var content = '￥' + value + '元';
					return content;
				}
			}, {
				id: 'user_name',
				title: '申请人',
				type: 'string',
				width: 75,
				columnClass: 'text-center'
			}, {
				id: 'create_time',
				title: '申请时间',
				type: 'date',
				width: 100,
				format: 'yyyy-MM-dd',
				otype: 'time_stamp_ms',
				columnClass: 'text-center'
			}, {
				id: 'useTimeSycle',
				title: '使用周期',
				type: 'string',
				width: 200,
				columnClass: 'text-center',
				resolution: function (value, record, column, grid, dataNo, columnNo) {
					var content = '';
					if (record.budgetBegin == null || record.budgetBegin == "" || record.budgetBegin == undefined) {
						return content;
					} else {
						content += record.budgetBegin + "至" + record.budgetEnd;
						return content;
					}

				}
			}, {
				id: 'comments',
				title: '费用说明',
				type: 'string',
				columnClass: 'text-left'
			}];

			$("#other2Container").empty();
			var other2Option = {
				lang: 'zh-cn',
				ajaxLoad: false,
				extraWidth: 20,
				// loadURL:'url',
				exportFileName: '其他费用',
				datas: response.data,
				columns: other2Columns,
				gridContainer: 'other2Container',
				tools: ''
			};
			var other1Grid = $.fn.dlshouwen.grid.init(other2Option);
			other1Grid.load();
		});
	}

	loadTotalBuget();

    function loadTotalBugetfy() {
        $certusUtils.ajax("findBugetInfo2", { "proId": proId, "status": 1,"isFy":1 }, function (response) {
            // 立项信息-项目指标
            var other2Columns = [{
                id: 'buget_phase',
                title: '阶段',
                type: 'string',
                width: 100,
                columnClass: 'text-center',
            }, {
                id: 'buget_type',
                title: '类型',
                type: 'string',
                width: 100,
                columnClass: 'text-center',
            }, {
                id: 'fmBuget',
                title: '金额',
                type: 'string',
                width: 150,
                columnClass: 'text-center',
                resolution: function (value, record, column, grid, dataNo, columnNo) {
                    var content = '￥' + value + '元';
                    return content;
                }
            }, {
                id: 'user_name',
                title: '申请人',
                type: 'string',
                width: 75,
                columnClass: 'text-center'
            }, {
                id: 'create_time',
                title: '申请时间',
                type: 'date',
                width: 100,
                format: 'yyyy-MM-dd',
                otype: 'time_stamp_ms',
                columnClass: 'text-center'
            }, {
                id: 'useTimeSycle',
                title: '使用周期',
                type: 'string',
                width: 200,
                columnClass: 'text-center',
                resolution: function (value, record, column, grid, dataNo, columnNo) {
                    var content = '';
                    if (record.budgetBegin == null || record.budgetBegin == "" || record.budgetBegin == undefined) {
                        return content;
                    } else {
                        content += record.budgetBegin + "至" + record.budgetEnd;
                        return content;
                    }

                }
            }, {
                id: 'comments',
                title: '费用说明',
                type: 'string',
                columnClass: 'text-left'
            }];

            $("#other2Container").empty();
            var other2Option = {
                lang: 'zh-cn',
                ajaxLoad: false,
                extraWidth: 20,
                // loadURL:'url',
                exportFileName: '其他费用',
                datas: response.data,
                columns: other2Columns,
                gridContainer: 'fyContainer',
                tools: ''
            };
            var other1Grid = $.fn.dlshouwen.grid.init(other2Option);
            other1Grid.load();
        });

        $certusUtils.ajax("findTotalMoney", { "proId": proId, "status": 1,"isFy":1 }, function (response) {
            var m = 0;
            if(response.data!=""){
                m = response.data;
            }
            $("#fyMoney").html(m);
        });
    }

    loadTotalBugetfy();

	this.addOtherMoney = function () {
		var bugetMoney = $("#bugetMoney").val();
		var comments = $("#comments").val();
		if (bugetMoney == "") {
			layer.msg("预算金额不能为空", { time: 1000 });
			return;
		}
		if (comments == "") {
			layer.msg("事由不能为空", { time: 1000 });
			return;
		}
		if (comments.length > 120) {
			layer.msg("事由不能超过120字", { time: 1000 });
			return;
		}
		var data = new Date();
		var datetime = $("#startTime").val();
		var startTime = new Date(datetime.replace("/", "-").replace("/", "-"));
		if (datetime != "") {
			if (startTime > data) {
				layer.msg("开始日期不能大于当前日期", { time: 1000 });
				return;
			}
		} else {
			layer.msg("开始日期不能为空", { time: 1000 });
			return;
		}
		var endTime = $("#endTime").val();
		if (endTime == "") {
			layer.msg("结束日期不能为空", { time: 1000 });
			return;
		}
		var endTimes = new Date(endTime.replace("/", "-").replace("/", "-"));
		if (startTime > endTimes) {
			layer.msg("开始日期不能大于结束日期", { time: 1000 });
			return;
		}

		var arr = {};
		if (proBaseInfo.stageCode == "1") {
			arr.phaseCode = "XS";
			arr.bugetPhase = "线索阶段";
		} else if (proBaseInfo.stageCode == "2") {
			arr.phaseCode = "LX";
			arr.bugetPhase = "运作阶段";
		} else if (proBaseInfo.stageCode == "3") {
			arr.phaseCode = "TB";
			arr.bugetPhase = "运作阶段";
		} else if (proBaseInfo.stageCode == "4") {
			arr.phaseCode = "HT";
			arr.bugetPhase = "合同阶段";
		} else if (proBaseInfo.stageCode == "5") {
			arr.phaseCode = "JF";
			arr.bugetPhase = "交付阶段";
		} else {
			arr.phaseCode = "HK";
			arr.bugetPhase = "回款阶段";
		}
		// arr.id = om;
		arr.bugetMoney = bugetMoney;
		arr.comments = comments;
		arr.bugetType = $("#bugetType").val();
		arr.startTime = $("#startTime").val();
		arr.endTime = $("#endTime").val();
		arr.proId = proId;
		// arr.useTimeSycle = $("#startTime").val()+"至"+$("#endTime").val();
		// otherMoneyData.push(arr);
		// om++;
		// otherGrid.load();
		$certusUtils.ajax("addProBuget", { "param": JSON.stringify(arr) }, function () {
			loadTotalBuget();
            searchTotal();
			$(".hideother").hide();
		});
	};

	// 项目费用报销记录
	var costColumns = [{
		id: 'filenav',
		title: '项目阶段',
		width: 100,
		type: 'string',
		columnClass: 'text-center',
	}, {
		id: 'filetype',
		title: '报销单号',
		width: 130,
		type: 'string',
		columnClass: 'text-center',
	}, {
		id: 'filelv',
		title: '报销总金额',
		width: 100,
		type: 'string',
		columnClass: 'text-center',
		resolution: function (value, record, column, grid, dataNo, columnNo) {
			var content = '￥' + value + '元';
			return content;
		}
	}, {
		id: 'fileName',
		title: '申请人',
		width: 70,
		type: 'string',
		columnClass: 'text-center',
	}, {
		id: 'filemsg',
		title: '审批日期',
		type: 'string',
		width: 100,
		columnClass: 'text-left',
	}, {
		id: 'uname',
		title: '其他说明',
		type: 'string',
		columnClass: 'text-left',
	}, {
		id: 'operation',
		title: '操作',
		type: 'string',
		width: 50,
		columnClass: 'text-center',
		resolution: function (value, record, column, grid, dataNo, columnNo) {
			var content = '';
			content += '<button class="btn btn-xs btn-primary" onclick="cost(' + record.id + ');"><i class="icon-eye-open"></i>  查看</button>';
			return content;
		}
	}];
	var costOption = {
		lang: 'zh-cn',
		ajaxLoad: false,
		extraWidth: 20,
		// loadURL:'url',
		exportFileName: '项目费用报销记录',
		datas: [{
			id: 1,
			filenav: '线索阶段',
			filetype: 'NJ201809091223',
			fileName: '张三测试',
			filemsg: '2010-08-02',
			filelv: '￥99999.00元',
			uname: '其他说明测试数据',
		},],
		columns: costColumns,
		gridContainer: 'costContainer',
		toolbarContainer: 'costToolBarContainer',
		tools: '',
		pageSize: 10,
		pageSizeLimit: [10, 15, 20]
	};
	var costGrid = $.fn.dlshouwen.grid.init(costOption);
	costGrid.load();
}
//已批准预算
$certusUtils.ajax('findWpzMoney', { "proId": proId,"status":1 }, function (response) {
	var m = 0;
	if(response.data!=""){
		m = response.data;
	}
	$("#wpzMoney").html(m);
});
$certusUtils.ajax('findProContract', { "proId": proId }, function (response) {
	var other2Columns = [{
		id: 'contractName',
		title: '合同名称',
		type: 'string',
		columnClass: 'text-center',
	}, {
		id: 'contractNo',
		title: '合同编号',
		type: 'string',
		columnClass: 'text-center',
	}, {
		id: 'contractAmount',
		title: '合同金额',
		type: 'string',
		width: 150,
		columnClass: 'text-center',
		resolution: function (value, record, column, grid, dataNo, columnNo) {
			var content = '￥' + value + '元';
			return content;
		}
	}, {
		id: 'consignee',
		title: '签订人',
		type: 'string',
		width: 75,
		columnClass: 'text-center'
	}, {
		id: 'contractSignTime',
		title: '签订时间',
		type: 'date',
		width: 100,
		format: 'yyyy-MM-dd',
		otype: 'time_stamp_ms',
		columnClass: 'text-center'
	},
	//     {
	//     id: 'softIncome',
	//     title: '软件收入',
	//     type: 'string',
	//     columnClass: 'text-center',
	// },{
	//     id: 'notSoftIncome',
	//     title: '非软件收入',
	//     type: 'string',
	//     columnClass: 'text-center',
	// },
	{
		id: 'keyTerms',
		title: '关键条款',
		type: 'string',
		columnClass: 'text-left'
	}];

	$("#htContainer").empty();
	var other2Option = {
		lang: 'zh-cn',
		ajaxLoad: false,
		extraWidth: 20,
		// loadURL:'url',
		exportFileName: '合同信息',
		datas: response.data,
		columns: other2Columns,
		gridContainer: 'htContainer',
		tools: ''
	};
	var other1Grid = $.fn.dlshouwen.grid.init(other2Option);
	other1Grid.load();
});

//项目支出费用
$certusUtils.ajax('expenditure/findProjExpenses', { "projId": proId }, function (response) {
    var other2Columns = [{
        id: 'name',
        title: '申请人',
        type: 'string',
        columnClass: 'text-center',
		width:90,
        resolution: function (value, record) {
            var content = record.inititorName+"("+record.inititorId+")";
            return content;
        }
    }, {
        id: 'expenses',
        title: '费用',
        type: 'string',
		width:60,
        columnClass: 'text-center',
    }, {
        id: 'income',
        title: '收入',
        type: 'string',
        width:60,
        columnClass: 'text-center',
    },{
        id: 'subclass',
        title: '类型',
        type: 'string',
		width:70,
        columnClass: 'text-center'
    }, {
        id: 'createTime',
        title: '申请时间',
        type: 'date',
        format: 'yyyy-MM-dd',
        otype: 'time_stamp_ms',
        width: 90,
        columnClass: 'text-center'
    }, {
        id: 'reason',
        title: '申请理由',
        type: 'string',
        width: 250,
        columnClass: 'text-center'
    },
        {
            id: 'flowState',
            title: '状态',
            type: 'string',
            width: 60,
            columnClass: 'text-center'
        }];

    $("#epContainer").empty();
    $("#epToolContainer").empty();
    var other2Option = {
        lang: 'zh-cn',
        ajaxLoad: false,
        extraWidth: 20,
        // loadURL:'url',
        exportFileName: '项目支出信息',
        datas: response.data,
        columns: other2Columns,
        gridContainer: 'epContainer',
        toolbarContainer: 'epToolContainer',
        tools: '',
        pageSize: 10,
        pageSizeLimit: [10, 15, 20]
    };
    var other1Grid = $.fn.dlshouwen.grid.init(other2Option);
    other1Grid.load();
});


//费用申请记录
function findCostbxInfo() {

}
function cost(id) {
	toLoadHtml(28, id);
}
function findCostDetail(id) {

}
function toBack() {
	toLoadHtml(29);
}
function hideother() {
	$(".hideother").hide();
};

function showother() {
	$(".hideother").show();
};

function deleteWarn(wid) {
	var dArr = {};
	for (var i = 0; i < otherMoneyData.length; i++) {
		if (otherMoneyData[i].id == wid) {
			dArr = otherMoneyData[i];
		}
	}
	otherMoneyData.splice($.inArray(dArr, otherMoneyData), 1);
	otherGrid.load();
};
$(".submit").on('click', function () {
	if (otherMoneyData.length <= 0) {
		return;
	}
	var proStage = "";
	if (proBaseInfo.stageCode == "1") {
		proStage = "XS";
	} else if (proBaseInfo.stageCode == "2") {
		proStage = "LX";
	}
	$certusUtils.ajax("addProBuget", { "param": JSON.stringify(otherMoneyData), "proId": proId, "proStage": proStage }, function (response) {
		toLoadHtml(30);
		layer.msg("申请成功");
	})
})